﻿@{
    ViewBag.Title = "Form"; 
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common','optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('adminform');
        //此处需修改
        //类型为时间时
           laydate.render({
              elem: '#F_HeadDate'
             
              , trigger: 'click',
              format: 'yyyy-MM-dd',
          });

        $(function () {
            initControl();
            if (!!keyValue) {
                 common.ajax({
                    url: '/PerformanceManagement/Arewpunrecordsrecords/GetFormJson',
                   dataType: 'json',
                   data: { keyValue: keyValue },
                   async: false,
                   success: function (data) {

                       common.val('adminform', data);
                        var d=new Date(data.F_HeadDate);
                           $('#F_HeadDate').val(d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDay());
                    }
               });
           }
           form.render();
       });
       wcLoading.close();

       function initControl() {
           //此处需修改
           //绑定数据源
           //类型为下拉框时
              $("#F_DutyId").bindSelect({
                  url: "/SystemOrganize/Duty/GetListJson",
                  id: "F_Id",
                  text: "F_FullName"
              });
                 $("#F_HolidayTypeId").bindSelect({
                    url: "/AttendanceManagement/Holidaytype/GetListJson",
                 id: "F_Id",
                  text: "F_FullName"
                });

             var code = new Date().formatDate('yyyyMMddhhmmss');
              $('#F_EnCode').val(code);
       }

       //监听提交
       form.on('submit(saveBtn)', function (data) {
           var postData = data.field;
                if (!postData["F_ArewardsPunishmentsMark"]) postData["F_ArewardsPunishmentsMark"] = false;
           common.submitForm({
                url: '/PerformanceManagement/Arewpunrecordsrecords/SubmitForm?keyValue=' + keyValue,
               param: postData,
               success: function () {
                   common.parentreload('data-search-btn');
               }
           })
           return false;
       });
   });
     function search(fileds) {
          layui.use(['jquery', 'form', 'common'], function () {
              var form = layui.form,
                  $ = layui.$,
                  common = layui.common;
              //不同弹窗
               if (fileds == '部门') {
                  common.modalOpen({
                      title: "选择组织",
                      url: "/SystemOrganize/Organize/AddForm?name=" + "F_OrganizeName" + "&value=" + "F_OrganizeId" + "&ids=" + $('#F_OrganizeId').val() + "&managerkey=" + $('#F_ManagerId').val() + "&managername=" + $('#F_ManagerName').val(),
                      width: "650px",
                      height: "600px",
                  });
              }
             else if (fileds == '人员') {
                      common.modalOpen({
                          title: "选择用户",
                            url: "/SystemOrganize/User/AddForm3?name=" + "F_RealName" + "&num="+"F_UserNum"+"&value=" + "F_UserId" + "&ids=" + $('#F_UserId').val(),
                           width: "650px",
                          height: "600px",
                      });
                  }
              else {
                  return false;
              }
          });
      }
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">编号</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_EnCode" name="F_EnCode" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" >
                       

                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md6 layui-col-sm6 layui-hide">
                        <label class="layui-form-label required">日期</label>
                        <div class="layui-input-block">
                            <input type="text" id="F_HeadDate" name="F_HeadDate" autocomplete="off" lay-verify="required" placeholder="请输入" lay-filter="a" class="layui-input">
                        </div>
                    </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">工号</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_UserNum" name="F_UserNum" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" onclick="search('人员')">
                        <input id="F_UserId" name="F_UserId" type="text" hidden />
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">姓名</label>
                    <div class="layui-input-block">


                        <input id="F_RealName" name="F_RealName" type="text" lay-verify="required" maxlength="50" autocomplete="off" class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">部门</label>
                    <div class="layui-input-block">
                        <input id="F_OrganizeName" name="F_OrganizeName" type="text" lay-verify="required" maxlength="50" autocomplete="off" class="layui-input" onclick="search('部门')" />
                        <input id="F_OrganizeId" name="F_OrganizeId" type="text" hidden />
                    </div>
                </div>
          
              
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">分类</label>
                   <div class="layui-input-block">
                        <input id="F_ArewardsPunishmentsMark" name="F_ArewardsPunishmentsMark" type="checkbox" lay-skin="switch" lay-text="奖励|扣款" checked value="true">

                   </div>
               </div>
               
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">金额</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_Amount" name="F_Amount" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">标题</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_FullName" name="F_FullName" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">


                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">原因</label>
                   <div class="layui-input-block">
                        <textarea id="F_Description" name="F_Description" lay-verify="required" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
               </div>
              
                <div class="layui-form-item layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

